home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / daten / quickfile / arexx / address.xdme next >
Text File  |  1995-04-06  |  2KB  |  100 lines

  1. /*
  2.     This is an XDME macro to get an address from a QuickFile addressbook
  3.        and insert it into the current document
  4.     Called from xdme with command "rx1 address lastname"
  5.     This also works with DME but needs "rx1 address.xdme lastname"
  6.     Should be easy to adapt to a word processor
  7. */
  8.  
  9. options results
  10.  
  11. parse arg name
  12.  
  13. address "QUICKFILE.01"
  14.  
  15. /*
  16.     Try to find the QuickFile addressbook
  17. */
  18.  
  19. "setfile"
  20. if rc > 0 then
  21.     call ErrorProc "Error from setfile command"
  22.  
  23. if upper(result) ~= "ADDRESSBOOK" then
  24. do
  25.     "setfile addressbook"
  26.     if rc > 0 then do
  27.     "openfile 'QuickFile:QuickFile3/Examples/AddressBook/AddressBook'"
  28.     if rc > 0 then
  29.         call ErrorProc "Cannot find addressbook file"
  30.     end
  31. end
  32.  
  33. /*
  34.     Find the right record
  35. */
  36.  
  37. "goto" name         /* find the record - exact match not required */
  38.  
  39. /*
  40.     Get the field values
  41. */
  42.  
  43. "GETFIELD Lastname"
  44. lastname = result
  45. "getfield FirstName"
  46. firstname = result
  47. "getfield Street"
  48. street = result
  49. "getfield Place"
  50. place = result
  51. "getfield state"
  52. state = result
  53. "GETFIELD Country"
  54. country = result
  55. "getfield Postcode"
  56. postcode = result
  57.  
  58. /*
  59.     Pass them back to XDME. The results should like
  60.  
  61. Alan Wigginton
  62. 23 Carissa Street
  63. Shailer Park   QLD  4128
  64. Australia
  65.  
  66. Dear Alan,
  67.  
  68. */
  69.  
  70.  
  71. address     /* send commands back to original host */
  72.  
  73. "("firstname Lastname")"    /* This inserts text into the document */
  74. "return"                    /* This goes to the next line */
  75. "("street")"
  76. "return"
  77. "("place state postcode")"
  78. "return"
  79. "("country")"
  80. "return"
  81. "return"
  82. "return"
  83. "(Dear" firstname",)"
  84. "return"
  85. "return"
  86.  
  87. exit
  88.  
  89. /*-------------------------------
  90.     Return an error string
  91. -------------------------------*/
  92.  
  93. ErrorProc:
  94.  
  95. parse arg msg
  96.  
  97. address
  98. "("msg")"
  99. exit
  100.